package albert3d.gui;

import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;

import java.awt.event.KeyListener;

public class Input implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener {

	@Override
	public void mouseDragged(MouseEvent e) {
		
		if(a>e.getX())
			angleX += 5;
		else if(a<e.getX())
			angleX += -5;
		
		if(b>e.getY())
			angleY += 5;
		else if(b<e.getY())
			angleY += -5;
		
		a = e.getX();
		b = e.getY();
	}

	@Override
	public void mouseMoved(MouseEvent e) {
	}

	@Override
	public void keyPressed(KeyEvent e) {
		if(e.getKeyCode() == KeyEvent.VK_CONTROL)
			ct = true;
	}

	@Override
	public void keyReleased(KeyEvent e) {
		if(e.getKeyCode() == KeyEvent.VK_CONTROL)
			ct = false;
	}

	@Override
	public void keyTyped(KeyEvent e) {
		if(e.getKeyChar() == 'q')
			z += 0.5f;
		if(e.getKeyChar() == 'e')
			z -= 0.5f;
		if(e.getKeyChar() == 'd')
			x += 0.5f;
		if(e.getKeyChar() == 'a')
			x -= 0.5f;
		if(e.getKeyChar() == 'w')
			y += 0.5f;
		if(e.getKeyChar() == 's')
			y -= 0.5f;
	}

	@Override
	public void mouseClicked(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseEntered(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseExited(MouseEvent e) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent e) {
	}

	@Override
	public void mouseReleased(MouseEvent e) {
	}
	
	public float angleX = 0.0f;
	public float angleY = 0.0f;
	public float scale = 1.0f;
	public float a = 0.0f;
	public float b = 0.0f;
	public float z = -8.0f;
	public float x = 0.0f;
	public float y = 0.0f;
	private boolean ct = false;
	
	@Override
	public void mouseWheelMoved(MouseWheelEvent e) {
		int wr = e.getWheelRotation();
		
		if(wr<0)
			if(ct==true)
				scale+=2.0f;
			else
				scale+=0.5f;
		else if(wr>0)
			if(ct==true) {
				if(scale>2.0f)
					scale-=2.0f;
			} else {
				if(scale>0.5f)
					scale-=0.5f;
			}
		
	}
}
